package com.my.thread_pool;

public abstract class UserInfoDeal<T, R> {



    public void dealUserInfo(MyThreadPoolExecutor myThreadPoolExecutor, T param, R result){

        if(myThreadPoolExecutor != null){

            runAsync(myThreadPoolExecutor, param, result);
        }else{

            runSync(param, result);
        }
    }

    public abstract void deal(T param, R result);


    /**
     * @author zlx
     * @Description 添加到异步线程
     * @Date 3/19/21
     * @Param [myThreadPoolExecutor, param, result]
     * @return void
     **/
    private void runAsync(MyThreadPoolExecutor myThreadPoolExecutor, T param, R result){

        myThreadPoolExecutor.add(()->{
            deal(param, result);
        });

    }


    private void runSync(T param, R result){
        deal(param, result);
    }

}
